package com.lijinjiang.annotation04;

import java.lang.reflect.Method;

/**
 * @ClassName RunMethod
 * @Description TODO
 * @Author Li
 * @Date 2022/9/21 11:29
 * @ModifyDate 2022/9/21 11:29
 * @Version 1.0
 */
public class RunMethod {
    public static void main(String[] args) throws Exception {
        AnnotationDemo demo = new AnnotationDemo();
        // 1.获取class对象
        Class c = AnnotationDemo.class;

        // 2.获取所有方法
        Method[] methods = c.getDeclaredMethods();

        // 3.遍历
        for (Method method : methods) {
            // 4.判断是否有MyTest注解
            if (method.isAnnotationPresent(MyTest.class)){
                method.invoke(demo);
            }
        }
    }
}
